package org.gdpu.model;

import javax.persistence.*;

/**
 * 用户信息组
 */

@Entity
public class Person {

    /**
    用户系统序号
     */
    private Integer personId;
    /**
   用户登录账号
    */
    private String accout;
    /**
   用户密码
    */
    private String password;
    /**
   用户姓名
    */
    private String personName;
    /**
   是否可用
    */
    private Boolean enable = true;
    /**
   权限组
    */
    private Groups groups;
    /**
     * 组别
     */
    private Teams teams;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "personId", unique = true, nullable = false)
    public Integer getPersonId() {
        return personId;
    }

    public void setPersonId(Integer personId) {
        this.personId = personId;
    }

    @Column(length = 40,unique = true)
    public String getAccout() {
        return accout;
    }

    public void setAccout(String accout) {
        this.accout = accout;
    }

    @Column(length = 40)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(length = 20)
    public String getPersonName() {
        return personName;
    }

    public void setPersonName(String personName) {
        this.personName = personName;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    @ManyToOne
    @JoinColumn(name = "groupName")
    public Groups getGroups() {
        return groups;
    }

    public void setGroups(Groups groups) {
        this.groups = groups;
    }
    @ManyToOne
    @JoinColumn(name = "teamsName")
    public Teams getTeams() {
        return teams;
    }

    public void setTeams(Teams teams) {
        this.teams = teams;
    }

    public Person(String accout){
        super();
        this.accout = accout;
    }

    public Person(){
        super();
    }

    @Override
    public String toString(){
        return accout;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result
                + ((personId == null) ? 0 : personId.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Person other = (Person) obj;
        if (personId == null) {
            if (other.personId != null)
                return false;
        } else if (!personId.equals(other.personId))
            return false;
        return true;
    }
}
